package org.example.utils;

import com.aliyun.dysmsapi20170525.Client;
import com.aliyun.teaopenapi.models.Config;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

/**
 * @author zqtao
 */
@Component
public class SmsClientConfig {

    //阿里云账号的accessKeyId
//    @Value("${aliyun.sms.sms-access-key-id}")
    private String accessKeyId  = "LTAI5tCTeQz3oNgM5UBAXkfF";
//    阿里云账号的accessKeySecret
//    @Value("${aliyun.sms.sms-access-key-secret}")
    private String accessKeySecret = "QOSgG8HWwO6WNKIu4SVjPPyMjyCPpc";
    //短信服务访问的域名
//    @Value("${aliyun.sms.sms-endpoint}")
    private String endpoint = "dysmsapi.aliyuncs.com";

    @Bean("smsClient")
    public Client createClient() throws Exception {
        Config config = new Config().setAccessKeyId(accessKeyId).setAccessKeySecret(accessKeySecret);
        config.endpoint = endpoint;
        return new Client(config);
    }
}
